home *** CD-ROM | disk | FTP | other *** search
/ PsL Monthly 1994 December / PSL Monthly Shareware CD-ROM (Public Software Library)(December 1994).bin / prgmming / dos / basic2 / qbfont.lst < prev    next >
File List  |  1989-03-22  |  3KB  |  116 lines

  1. Summary:
  2.  
  3. The method described in this article will allow you to display a
  4. user-defined character set of up to 256 characters in Hercules
  5. graphics mode. Notice that this method only works in Hercules graphics
  6. mode (SCREEN 3) and does not work under MS OS/2.
  7.  
  8. This information applies to Microsoft QuickBASIC Versions 4.00, 4.00b,
  9. 4.50 and Microsoft BASIC Compiler Versions 6.00 and 6.00b for MS-DOS
  10. and OS/2.
  11.  
  12. More Information:
  13.  
  14. It is possible to modify two assembly-language programs available in
  15. "Programmer's Guide To PC & PS/2 Video Systems," by Richard Wilton
  16. (Published by Microsoft Press), to display user-defined character
  17. fonts in the graphics mode.
  18.  
  19. The first program, PixelAddrHGC, is Listing 4-3. This program computes
  20. the starting address of the first pixel for the data to be displayed.
  21. The main assembly program, DisplayCharHGC, is shown in Listing 9-4.
  22.  
  23. As written, these programs are meant to interface with Microsoft C. To
  24. change them to work with BASIC, do the following:
  25.  
  26. 1. Change all near references to far (use memory-model medium).
  27.  
  28. 2. Remove the underscore in the public name.
  29.  
  30. 3. Create storage space for VARmask, VARtoggle, and VAR9bits in
  31.    DGROUP.
  32.  
  33. 4. Reverse the input order of the arguments. Instead of using
  34.    interrupt vector 43 hex to point to the first 128 characters, and
  35.    1F hex to point to the font table containing the rest of the
  36.    characters, use an unused interrupt vector to point to a single
  37.    table containing 256 characters.
  38.  
  39. 5. Set DS == ES.
  40.  
  41. The BASIC program below calls a modified form of DisplayCharHGC to
  42. print a user-defined font to the screen. This program works correctly
  43. in the QuickBASIC environment and in stand-alone executable form.
  44.  
  45. The following is a code example:
  46.  
  47. ' $INCLUDE: 'q:qb.bi'
  48. DECLARE SUB DisplayCharHGC (BYVAL A%, BYVAL x%, BYVAL y%,_
  49.              BYVAL f%, BYVAL b%)
  50. DEFINT A-Z
  51. DIM RegX AS RegtypeX
  52.  
  53. ' set table large enough to hold the character set
  54. DIM table(2048) ' 256 * 8
  55.  
  56. ' table is common to put it in the DGROUP
  57. COMMON table()
  58.  
  59. DATA 2,6,14,30,62,126,254,0
  60. DATA 254,64,32,16,32,64,254,0
  61. DATA 132,136,158,162,70,130,14,0
  62.  
  63. CLS
  64. SCREEN 3
  65. DEF SEG = VARSEG(table(0))
  66. FOR i = 1 TO 24
  67.    READ A%   'Place the created characters into the new
  68.    POKE VARPTR(table(0)) + i, A%    'graphics table
  69. NEXT i
  70. DEF SEG
  71.  
  72.  'get the initial value at interrupt 50 hex
  73.    RegX.Ax = &H3550
  74.    RegX.Ds = -1
  75.    RegX.Es = -1
  76.    CALL interruptX(&H21, RegX, RegX)
  77.    PRINT "Vector 50H was "; RegX.Es, RegX.Bx
  78.    oldoff& = RegX.Es
  79.    oldPtr& = RegX.Bx
  80.  
  81.  ' reset interrupt 50 hex to point to table of characters
  82.    RegX.Ax = &H2550
  83.    RegX.Ds = VARSEG(table(0))
  84.    RegX.Dx = VARPTR(table(0))
  85.    CALL interruptX(&H21, RegX, RegX)
  86.  
  87.  ' verify the reset took
  88.    RegX.Ax = &H3550
  89.    RegX.Ds = -1
  90.    RegX.Es = -1
  91.    CALL interruptX(&H21, RegX, RegX)
  92.    PRINT "New vector "; RegX.Es, RegX.Bx
  93.    A% = 10
  94.  
  95. ' print characters
  96. FOR i = 0 TO 2
  97.         A% = A% + 1
  98.         CALL DisplayCharHGC(i, 20, 20 * A%, 0, 7)
  99. NEXT
  100.  
  101. 'restore original vector
  102.    RegX.Ds = oldoff&
  103.    RegX.Dx = oldPtr&
  104.    RegX.Ax = &H2550
  105.    CALL interruptX(&H21, RegX, RegX)
  106.  
  107. 'verify restoration
  108.    RegX.Ax = &H3550
  109.    RegX.Ds = -1
  110.    RegX.Es = -1
  111.    CALL interruptX(&H21, RegX, RegX)
  112.    PRINT "Vector 50H reset to "; RegX.Es, RegX.Bx
  113.  
  114. ' pause
  115.    SLEEP
  116.